const enterpriseVue = new Vue({
  el: '#app',
  data() {
    return {
      pickerOptions: pickerOptions,
      rules: {
        title: [{
          required: true,
          message: '请输入交易说明标题',
          trigger: 'blur',
        }],
        content: [{
          required: true,
          message: '请输入交易说明内容',
          trigger: 'blur',
        }],
      },
      fileList2: [{ name: 'food.jpeg', url: '../../../../admin/images/act.jpg' }],
      dialogImageUrl: '',
      dialogVisible: false,
      form: {
        title: '',
        Data: [
          {
            content: ''
          }
        ],
      },
      loading: false
    }
  },
  mounted() {

  },
  methods: {
    submitForm(formName) {
      let _this = this
      this.$refs[formName].validate((valid) => {
        if (valid) {
          _this.loading = true
          $.ajax({
            url: DomainName + '/GoodsFileAdd',
            type: 'POST',
            data: {
              Data: JSON.stringify({
                item: [_this.form]
              }),
              token: $.cookie("token")
            },
            success: function (res) {
              console.log('提交结果', res)
              _this.$message.success("提交成功")
              window.history.go(-1)
            },
            error: function () {
              _this.$message.error("操作失败，请稍后再试")
            },
            complete: function (XMLHttpRequest) {
              _this.loading = false
              if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
                window.parent.document.location.href = "../../../" + XMLHttpRequest.getResponseHeader("CONTENTPATH");
              }
            }
          })
        } else {
          console.log("error submit!!");
          return false;
        }

      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    },
    Add() {
      this.form.Data.push({
        content: ''
      })
    },
    Rdc() {
      if (this.form.Data.length > 1) {
        this.form.Data.pop()
      } else {
        this.$message.error('不能再删除了')
      }
    }
  }
})